#include "Minimax.h"

#define BOOST_TEST_MODULE MyTest
#include <boost/test/unit_test.hpp>

class TestEvaluator :
	public GameStateEvaluator
{
public:
	virtual
	int		evaluate(GameState* state)
	{
		GamePlayer& mutableThis = *this;
		return state->score(0);
	} // end method

	virtual
	void	observeStateTransition(SeatNumber, GameState*, GameState*) {}

	virtual
	void	startTurn(Authority*) {}
}; // end class

class TestState : public GameState
{
public:
	TestState(
		TestEvaluator*	p,
		GameState*		a,
		GameState*		b,
		const int		s = 0
	) : player(p), value(s)
	{
		list = new StateList(0);
		if (NULL != a)
		{
			list->push_back(a);
			list->push_back(b);
		}
	} // end constructor

	TestState(
		TestEvaluator*	p,
		const int	s = 0
	) : player(p), value(s)
	{
		list = new StateList(0);
	} // end constructor

	GamePlayer*	getActivePlayer()
	{
		return player;
	} // end method

	virtual
	GameState*	getNextSequence()
	{
		return NULL;
	} // end method

	StateList& listAvailableActions()
	{
		return *list;
	} // end method

	virtual
	ExpectedValue score(SeatNumber)
	{
		return value;
	} // end method

private:
	const
	int				value;
	TestEvaluator*	player;
	StateList*		list;
}; // end class

TestEvaluator*	protagonist = new TestEvaluator();
TestEvaluator*	antagonist = new TestEvaluator();
GameState*
const			GameState::NONE = new TestState(protagonist, NULL, NULL);
GameState*
const			GameState::INITIAL = NULL;
GameState*
const			LEAF0 = new TestState(antagonist, 5);
GameState*
const			LEAF1 = new TestState(antagonist, 4);
GameState*
const			LEAF2 = new TestState(antagonist, 6);
GameState*
const			LEAF3 = new TestState(antagonist, 2);
GameState*
const			LEAF4 = new TestState(antagonist, 7);
GameState*
const			LEAF5 = new TestState(antagonist, 8);
GameState*
const			LEAF6 = new TestState(antagonist, 4);
GameState*
const			LEAF7 = new TestState(antagonist, 4);
GameState*
const			MID_BRANCH0 = new TestState(protagonist, LEAF0, LEAF1);
GameState*
const			MID_BRANCH1 = new TestState(protagonist, LEAF2, LEAF3);
GameState*
const			MID_BRANCH2 = new TestState(protagonist, LEAF4, LEAF5);
GameState*
const			MID_BRANCH3 = new TestState(protagonist, LEAF6, LEAF7);
GameState*
const			ROOT_LEFT_BRANCH = new TestState(antagonist, MID_BRANCH0, MID_BRANCH1);
GameState*
const			ROOT_RIGHT_BRANCH = new TestState(antagonist, MID_BRANCH2, MID_BRANCH3);
TestState		root(protagonist, ROOT_RIGHT_BRANCH, ROOT_LEFT_BRANCH);
/*
int main( int argc, const char* argv[] )
{
	Minimax test(protagonist);
	GameState* result = test.getBestAction(&root);
	bool equivalence = (ROOT_LEFT_BRANCH == result);
} // end method
*/

#include "GrudgeEvaluator.h"
GameEngine* const GameEngine::singleton = new GameEngine();

BOOST_AUTO_TEST_CASE( userID_createAccount )
{
	string myName = "James";
//	string notMyName = "Blames";

    TestEvaluator p;
	p.setAccountName(myName);
//	p.setAccountName(notMyName);

	string firstAIName = "Eliza";
	GrudgeEvaluator e(firstAIName);
} // end test


#include "PlayingCard.h"

enum StandardValues {ACE = 1, DEUCE, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, FACE_VALUE_COUNT = 13};
enum StandardSuits {SPADES, HEARTS, CLUBS, DIAMONDS, SUIT_COUNT};
typedef PlayingCard<StandardValues, StandardSuits> StandardCard;

BOOST_AUTO_TEST_CASE( game_playingCardOperations )
{
	StandardCard** d = StandardCard::generateDeck(ACE, SPADES);
	StandardCard::shuffle(d);
	StandardCard::sort(d);
} // end test


